package com.smart.system.domain;

import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.smart.common.annotation.Excel;
import com.smart.common.core.domain.BaseEntity;

import java.util.List;

/**
 * 员工移动轨迹对象 employee_trajectory
 * 
 * @author smart
 * @date 2024-09-18
 */
@Data
@Builder
@TableName("employee_trajectory")
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
public class EmployeeTrajectory extends BaseEntity
{
    private static final long serialVersionUID = 1L;


    /** 主键标识 */
    @Schema(description ="${comment}")
    @TableField(value = "id",exist = true)
    @TableId(type = IdType.AUTO)
    private Integer id;

    @Schema(description ="排序")
    @TableField(value = "sort",exist = false)
    private Integer sort;

    /** 部门号 */
    @Excel(name = "部门号")
    @Schema(description ="部门号")
    @TableField(value = "dept_id",exist = true)
    private Long deptId;

    /** 乐观锁 */
    @Excel(name = "乐观锁")
    @Schema(description ="乐观锁")
    @TableField(value = "revision",exist = true)
    private Integer revision;

    /** 是否删除;0正常1删除 */
    @Schema(description ="是否删除")
    @TableField(value = "del_flag",exist = true)
    private String delFlag;

    /** 是否启用;0正常1冻结 */
    @Excel(name = "是否启用;0正常1冻结")
    @Schema(description ="是否启用;0正常1冻结")
    @TableField(value = "status",exist = true)
    private String status;

    /** 位置json **/
    @Excel(name = "位置json禁止使用,请使用areaLocation")
    @Schema(description ="位置json")
    @TableField(value = "json_string",exist = true)
    private String jsonString;

    @Schema(description = "坐标经纬度类")
    @TableField(exist = false)
    private AreaLocation areaLocation;

    @Schema(description = "用户id")
    @TableField(exist = true)
    private Integer userId;

    @Schema(description = "用户信息")
    @TableField(exist = false)
    private Employee employee;

    public void setJsonString(String jsonString) {
        this.jsonString = jsonString;
        this.areaLocation = JSON.parseObject(jsonString, AreaLocation.class);
    }

    public void setAreaLocation(AreaLocation areaLocation) {
        this.areaLocation = areaLocation;
        this.jsonString = JSON.toJSONString(areaLocation);
    }
    public AreaLocation getAreaLocation(){
        return JSON.parseObject(jsonString, AreaLocation.class);
    }
}
